package ro.cityprojects.adminloc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import ro.cityprojects.adminloc.entities.Apartment;
import ro.cityprojects.adminloc.exceptions.ValidationException;
import ro.cityprojects.adminloc.service.ApartmentsService;

/**
 * ApartmentsController
 *
 * @author bogdan.solga
 *
 * Date: 17/10/13, time: 18:27
 */
@Controller
@RequestMapping(value = "/apartments")
public class ApartmentsController extends BaseController<Integer, Apartment> {

    @Autowired
    private ApartmentsService apartmentsService;

    @Override
    public void save(Apartment apartment) throws ValidationException {
        apartmentsService.save(apartment);
    }

    @Override
    public String get(@PathVariable Integer integer, @RequestParam(required = false) String includedFields) {
        return apartmentsService.get(integer, includedFields);
    }

    @Override
    public String get(@RequestParam(required = false) String name, @RequestParam(required = false) String value,
                      @RequestParam(required = false) String includedFields) {
        return apartmentsService.getAll(name, value, includedFields);
    }

    @Override
    public void update(Apartment entity, Integer integer) {
        apartmentsService.update(entity, integer);
    }

    @Override
    public void delete(Integer integer) {
        apartmentsService.delete(integer);
    }

    @Override
    public String getMetadata() {
        return apartmentsService.getMetadata();
    }
}
